package cn.ztuo.bitrade.controller;


import cn.ztuo.bitrade.entity.RechargeRecord;
import cn.ztuo.bitrade.entity.transform.AuthMember;
import cn.ztuo.bitrade.service.RechargeRecordService;
import cn.ztuo.bitrade.util.MessageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.SessionAttribute;

import static cn.ztuo.bitrade.constant.SysConstant.SESSION_MEMBER;


@RestController
@RequestMapping(value = "/rechargeRecord")
public class RechargeRecordController {

    @Autowired
    private RechargeRecordService rechargeRecordService;


    @PostMapping("save")
    public synchronized MessageResult save(@SessionAttribute(SESSION_MEMBER) AuthMember member, RechargeRecord rechargeRecord) {

        rechargeRecord.setUsername(member.getName());
        rechargeRecord.setMemberId(member.getId());
        rechargeRecord.setMobilePhone(member.getMobilePhone());

        rechargeRecordService.save(rechargeRecord);

        return MessageResult.success("保存成功");
    }

}
